import delimited "/Users/michaelalbertus/Dropbox/Research/Indigenous Communities in Peru/Paper on Recognition and Conflict/JCR/R&R/Replication files/CCpanel.csv"

keep if p_year==1990
gen f_year = real(fecha_year)
gen frecon_year = real(fechareconocimiento_year)
replace f_year=0 if f_year==.

replace frecon_year =0 if frecon_year==.
keep if f_year>1989 | frecon_year>1989

gen recogyear = f_year
replace recogyear = frecon_year if f_year==.
replace recogyear = frecon_year if f_year==0

gen rp049 = real(p049)
replace rp049 = 0 if rp049==2

gen yearssincerecog = 2012-recogyear
bys yearssincerecog: egen rp049_av2 = mean(rp049)

twoway scatter rp049_av2 yearssincerecog if yearssincerecog>-3 & yearssincerecog<21, xlabel(-2 0 2 4 6 8 10 12 14 16 18 20) xtitle("Years since recognition as of 2012 census") ytitle("Share of communities with land conflicts")
